<?php
header("Content-Type:json/html;charset=utf8");

$config = require '../config.php';
require '../validToken.php';
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);

    $id = $_POST['id'];
    $author = $_POST['author'];
    $content = $_POST['content'];
    $email = $_POST['email'];

    $sql = "insert into comment(article_id,  author, content, device) values ('$id','$author','$content','Windows 10 · QQ Browser')";
    $result = $conn->query($sql);
    $conn->close();

    if($result){
        $result = ['code' =>1,  'msg' => "发表评论成功!"];
        require "../util/savelog.php";
    }else{
        $result = ['code' =>0,   'msg' => "发表评论失败!"];
    }
print_r(json_encode($result));

